package com.mfcxy.admin.controller;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.xml.ws.RequestWrapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;

import com.baidu.ueditor.ActionEnter;

@Controller
@RequestMapping("/admin/ueditor/")
public class Ueditor {
	
	@Autowired
	private ServletContext servletContext;
	
	@ResponseBody
	@RequestMapping("config")
	public String index(HttpServletRequest request) {
		String action = request.getParameter("action");
		
		String strResult = "";
		String rootPath = servletContext.getRealPath( "/" );
		
		rootPath += "WEB-INF\\resources\\public\\ueditor\\jsp\\";
		
		System.out.println(rootPath);
		
		strResult = new ActionEnter( request, rootPath ).exec();
		
		/*ObjectMapper objMapper = new ObjectMapper();
		
		try {
			JsonNode rootNode = objMapper.readTree(new File(this.ueditorConfig));
			// 获得 json 字符串
			strResult = rootNode.toString();
		} catch (JsonProcessingException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}*/
		
		return strResult;
	}
}
